@echo off

rem ---------------------------------------------------------------------------
if "%~1" == "" goto noParameter
goto process

rem ---------------------------------------------------------------------------
:noParameter

rem graphic
call  %0  "-t4 -na"        _na32  variantsGraphic
call  %0  "-na"            _na    variantsGraphic
call  %0  "-ta"            _ta    variantsGraphic
call  %0  "-ta255,0,255"   _taM   variantsGraphic



rem gworld
if not exist extdec\*.g*        call  wiso\eGraphic.bat
if not exist ..\extracted\variantsGWorld_ta mkdir ..\extracted\variantsGWorld_ta
if exist extdec\3650.map (
    rem extract ranges, so no need delete duplicities
    ffxmap  -e -ta -r 0-6     extdec\3650.map   ..\extracted\variantsGWorld_ta\3650_
    ffxmap  -e -ta -r 10-11   extdec\3650.map   ..\extracted\variantsGWorld_ta\3650_
    ffxmap  -e -ta -r 29-30   extdec\3650.map   ..\extracted\variantsGWorld_ta\3650_
)


pause
exit

rem ---------------------------------------------------------------------------
:process


set gnopParams=%~1
set nameSuffix=%~2
set extractdir=%~3
set outname=

if not exist extdec\*.g*        call  wiso\eGraphic.bat

if not exist ..\extracted\%extractdir% mkdir ..\extracted\%extractdir%
if exist extracted\0225.gnop   ffxgnop -e1      %gnopParams%  extracted\0225.gnop  extracted\0223.mpal  ..\extracted\%extractdir%\0225%nameSuffix%.bmp
if exist extracted\0226.gnop   ffxgnop -e0      %gnopParams%  extracted\0226.gnop  extracted\0223.mpal  ..\extracted\%extractdir%\0226%nameSuffix%.bmp

rem 4bits
if exist extracted\0230.gnop   ffxgnop -e13,7   %gnopParams%  extracted\0230.gnop  extracted\0223.mpal  ..\extracted\%extractdir%\0230%nameSuffix%.bmp
if exist extracted\0229.gnop   ffxgnop -e13,0   %gnopParams%  extracted\0229.gnop  extracted\0223.mpal  ..\extracted\%extractdir%\0229%nameSuffix%.bmp
if exist extracted\0229.gnop   ffxgnop -e13,11  %gnopParams%  extracted\0229.gnop  extracted\0223.mpal  ..\extracted\%extractdir%\0229_miss%nameSuffix%.bmp
if exist extracted\0229.gnop   ffxgnop -e13,12  %gnopParams%  extracted\0229.gnop  extracted\0223.mpal  ..\extracted\%extractdir%\0229_immune%nameSuffix%.bmp
if exist extracted\0229.gnop   ffxgnop -e13,13  %gnopParams%  extracted\0229.gnop  extracted\0223.mpal  ..\extracted\%extractdir%\0229_overkill%nameSuffix%.bmp


rem extension may be pressent or missing
rem extracting 34th image from 0240
FOR %%i IN (extdec\0240*) DO ffxgnop -e  %gnopParams%  -pb 128,128,8,0x9A1D0  -pp 0x5920    %%i  %%i  ..\extracted\%extractdir%\%%~ni%nameSuffix%.bmp

FOR %%i IN (extdec\2986*) DO (
    ffxgnop  -e %gnopParams% -pb 256,128,8,0x25F00  -pp 0x242E0    %%i  %%i  ..\extracted\%extractdir%\%%~ni_0%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 256,128,8,0x2DF00  -pp 0x246E0    %%i  %%i  ..\extracted\%extractdir%\%%~ni_1%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 256,128,8,0x35F00  -pp 0x24AE0    %%i  %%i  ..\extracted\%extractdir%\%%~ni_2%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 256,128,8,0x3DF00  -pp 0x24EE0    %%i  %%i  ..\extracted\%extractdir%\%%~ni_3%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 256,128,8,0x45F00  -pp 0x252E0    %%i  %%i  ..\extracted\%extractdir%\%%~ni_4%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 256,128,8,0x4DF00  -pp 0x256E0    %%i  %%i  ..\extracted\%extractdir%\%%~ni_5%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 256,64,8,0x55F00   -pp 0x25AE0    %%i  %%i  ..\extracted\%extractdir%\%%~ni_6%nameSuffix%.bmp
)


if exist extdec\0175.gp   ffxgnop  -e %gnopParams% -pb 512,512,8,0x420   -pp 0x20     extdec\0175.gp  extdec\0175.gp  ..\extracted\%extractdir%\0175%nameSuffix%.bmp
if exist extdec\0181.gp   ffxgnop  -e %gnopParams% -pb 512,512,8,0x420   -pp 0x20     extdec\0181.gp  extdec\0181.gp  ..\extracted\%extractdir%\0181%nameSuffix%.bmp
if exist extdec\0178.gp (
    ffxgnop  -e %gnopParams% -pb 512,512,8,0x450   -pp 0x50     extdec\0178.gp  extdec\0178.gp  ..\extracted\%extractdir%\0178_0%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 512,512,8,0x40850 -pp 0x40450  extdec\0178.gp  extdec\0178.gp  ..\extracted\%extractdir%\0178_1%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 256,256,8,0x80C50 -pp 0x80850  extdec\0178.gp  extdec\0178.gp  ..\extracted\%extractdir%\0178_2%nameSuffix%.bmp
    ffxgnop  -e %gnopParams% -pb 256,256,8,0x91050 -pp 0x90C50  extdec\0178.gp  extdec\0178.gp  ..\extracted\%extractdir%\0178_3%nameSuffix%.bmp
)


rem if exist extdec\3738.map  ffxgnop  -e -pb 512,448,8,0x72D10  -pp 0xAAD50   extdec\3738.map  extdec\3738.map  ..\extracted\%extractdir%\3738.bmp
rem if exist extdec\3740.map  ffxgnop  -e -pb 512,448,8,0x1B0    -pp 0x381F0   extdec\3740.map  extdec\3740.map  ..\extracted\%extractdir%\3740.bmp
if exist extdec\3738.map  ffxmap -e3 %gnopParams% extdec\3738.map  ..\extracted\%extractdir%\3738%nameSuffix%.bmp
if exist extdec\3740.map  ffxmap -e0 %gnopParams% extdec\3740.map  ..\extracted\%extractdir%\3740%nameSuffix%.bmp



if not exist extdec\*.ev   call  wiso\eEV.bat

rem blitzball/misc graphic (not extracting duplicit)
ffxgnop  -e %gnopParams%   -pb 256,128,8,0x4719A0  -pp 0x4799A0,16,16,0,1   extdec\0348.ev  extdec\0348.ev  ..\extracted\%extractdir%\0348%nameSuffix%.bmp
ffxgnop  -e %gnopParams%   -pb 256,256,8,0x5A20    -pp 0x15A20,16,16,0,1    extdec\0547.ev  extdec\0547.ev  ..\extracted\%extractdir%\0547%nameSuffix%.bmp
ffxgnop  -e %gnopParams%   -pb 256,128,8,0xD5EA0   -pp 0xDDEA0,16,16,0,1    extdec\0739.ev  extdec\0739.ev  ..\extracted\%extractdir%\0739%nameSuffix%.bmp
ffxgnop  -e %gnopParams%   -pb 256,128,8,0x107A0   -pp 0x187A0,16,16        extdec\0830.ev  extdec\0830.ev  ..\extracted\%extractdir%\0830%nameSuffix%.bmp

rem pause
